package org.wolfengi.handler.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapreduce.lib.db.DBWritable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Author: wolfengi
 * @Description: ${TODO}
 * @Date: Created in 10:13 2020/5/19
 * @Modified By:
 */
@AllArgsConstructor
@Getter
@Setter
public class TableOperForShipDict implements Writable, DBWritable {

    private String mmsi;
    private float weight;
    private int ship_age;
    private String ship_type;
//    private String ship_cn;

    @Override
    public void readFields(DataInput in) throws IOException {
    }

    @Override
    public void readFields(ResultSet rs) throws SQLException {
        this.mmsi = rs.getString(1);
        this.weight = rs.getFloat(2);
        this.ship_age = rs.getInt(3);
        this.ship_type = rs.getString(4);
//        this.ship_cn = rs.getString(5);
    }

    @Override
    public void write(DataOutput out) throws IOException {
    }

    @Override
    public void write(PreparedStatement ps) throws SQLException {
        ps.setString(1, this.mmsi);
        ps.setFloat(2, this.weight);
        ps.setInt(3, this.ship_age);
        ps.setString(4, this.ship_type);
//        ps.setString(5, this.ship_cn);
    }
}
